﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Management;
using System.Text;

namespace WMI.NET.CIM
{
    /// <summary>
    /// The CIM_Service class represents a logical element that contains information to represent and manage the functionality provided by a device or software feature. A service is a general-purpose object to configure and manage the implementation of functionality; it is not the functionality itself.
    /// </summary>
    public class CIM_Service : CIM_LogicalElement
    {

        private string _CreationClassName;
        private Nullable<Boolean> _Started;
        private string _StartMode;
        private string _SystemCreationClassName;
        private string _SystemName;


        /// <summary>
        /// Name of the class or subclass used in the creation of an instance. When used with other key properties of the class, this property allows all instances of the class and its subclasses to be uniquely identified.
        /// </summary>
        public string CreationClassName { get { return _CreationClassName; } }

        /// <summary>
        /// If TRUE, the service has started.
        /// </summary>
        public Nullable<Boolean> Started { get { return _Started; } }

        /// <summary>
        /// Indicates whether the service is automatically started (for example, by an operating system) or only started upon request.
        /// </summary>
        public string StartMode { get { return _StartMode; } } //TODO enum

        /// <summary>
        /// Scoping system's creation class name.
        /// </summary>
        public string SystemCreationClassName { get { return _SystemCreationClassName; } }

        /// <summary>
        /// Name of the system that hosts the service.
        /// </summary>
        public string SystemName { get { return _SystemName; } }



        /// <summary>
        ///  The StartService method puts the service in a started state. 
        /// </summary>
        /// <returns></returns>
        public UInt32 StartService() { throw new NotImplementedException(); }


        /// <summary>
        /// The StopService method stops the service represented by the object derived from CIM_Service.
        /// </summary>
        /// <returns></returns>
        public UInt32 StopService() { throw new NotImplementedException(); }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="mbo"></param>
        public CIM_Service(ManagementBaseObject mbo)
            : base(mbo)
        {
            _CreationClassName = mbo.GetStringValue("CreationClassName");
            _Started = mbo.GetBoolValue("Started");
            _StartMode = mbo.GetStringValue("StartMode");
            _SystemCreationClassName = mbo.GetStringValue("SystemCreationClassName");
            _SystemName = mbo.GetStringValue("SystemName");
        }

    }
}
